﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;
using System.Collections;
using System.Configuration;


namespace DTC
{
    public partial class FrmIOTrace : UIBase
    {
        
        PISO730 iocard = PISO730.Instance;
        ArrayList arr = new ArrayList();
        public FrmIOTrace()
        {
            InitializeComponent();
            arr = ControlArrayUtils.getControlArray(this, "lbtip", "");
            List<TestItem> testItems = Product.ParseTestItems("TMC01.XML");
            if (testItems != null)
            {
                foreach (var item in testItems.Where(t=>t.IsUse==true))
                {
                    ((Label)arr[item.ItemLocation]).Text = item.ItemName.Trim('"').Contains("耐压") ? item.ItemName.Trim('"') + "结果" : item.ItemName.Trim('"') + "测试完成";
                }
               int io_alltestok =int.Parse( ConfigurationManager.AppSettings["IOAllTestOK"]);
               ((Label)arr[io_alltestok]).Text = "所有测试完成";
                int io_stop=int.Parse( ConfigurationManager.AppSettings["IOStopping"]);
                ((Label)arr[io_stop]).Text = "结束模式";

            }
             
           
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            uint DIVal = iocard.Read();
           arr = ControlArrayUtils.getControlArray(this, "pbout", "");
           for (int index = 0; index < 16; index++)
           {

               if ((DIVal & (1 << (index))) == 0)
               {
                   ((PictureBox)arr[index]).BackColor = Color.Gray;
               }
               else
               {
                   ((PictureBox)arr[index]).BackColor = Color.Red;
               }
           }
        }
    }
}
